package drawing;
import math.Ray;
import math.Triangle;
import math.Vector3f;


public class HitRecord {

	private Triangle triangle;
	private float alfa, beta, gamma, t;
	private Ray ray;
	
	public HitRecord(Triangle triangle, Ray ray, float alfa, float beta, float gamma, float t){
		this.triangle = triangle;
		this.alfa = alfa;
		this.beta = beta;
		this.gamma = gamma;
		this.t = t;
		this.ray = ray;
	}

	public float getT() {
		return this.t;
	}
	
	public Vector3f getNormal() {
		try {
			Vector3f result = triangle.getNormalA().scale(alfa).add(
					triangle.getNormalB().scale(beta).add(
							triangle.getNormalC().scale(gamma)));
			result = result.scale(1.0f/result.length());
			return result;
		} catch (Exception e) {
			return triangle.getNormal();
		}
	}
	
	public Ray getRay(){
		return this.ray;
	}
}
